package com.matchmealpha;

import java.util.ArrayList;

import android.app.ActivityGroup;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;

public class ShareGroup extends ActivityGroup{
	public static ShareGroup shareGroup;
	private ArrayList<View> shareHistory;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		this.shareHistory = new ArrayList<View>();
		shareGroup = this;

		View view = getLocalActivityManager().startActivity(
				"ShareActivity",
				new Intent(this, ShareActivity.class)
						.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP))
				.getDecorView();
		replaceView(view);
	}
	
	public void replaceView(View v) {
		shareHistory.add(v);
		setContentView(v);
	}
	
	public void back() {
		if (shareHistory.size() > 0) {
			shareHistory.remove(shareHistory.size() - 1);
			setContentView(shareHistory.get(shareHistory.size() - 1));
		} else {
			finish();
		}
	}
	
	@Override
	public void onBackPressed() {
		ShareGroup.shareGroup.back();
		return;
	}
}
